package com.hunttown.common.sharding.client.manager;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class MultipleTransactionProxy implements InvocationHandler {
    private Object target;

    public MultipleTransactionProxy() {
    }

    public Object bind(Object target) {
        this.target = target;
        return Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), this);
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        MultipleTransactionBaseManager base = (MultipleTransactionBaseManager) this.target;
        Object result = base.handleDataBase(this.target, method, args);
        return result;
    }
}